print('1.封装')
class Car:
    def __init__(self, brand):
        self.brand = brand
    def start(self):
        print('汽车已经启动!')
car = Car('宝马X5')
car.start()
print(car.brand)
print()

print('2.封装的第二种内部封装')
class Student:
    def __init__(self, name, age):
        self.name = name
        self.__age = age   #年龄不希望在外部被访问，所以使用了两个下划线
    def show(self):
        print(self.name, self.__age)
stu = Student('张三', 20)
stu.show()
#在内的外部使用name和age,只能查到name，不能查到age
print(stu.name)
#print(stu.age)
#print(dir(stu))
print(stu._Student__age)
print()

print('3.继承')


